Most versions of SQL Server 2008 can address the amount of memory
supported by the underlying operating system. However, like previous
versions, 32-bit editions of SQL Server 2008 are constrained to 2GB of
RAM unless configured with special settings. Let's begin our coverage of
memory configuration with a look at 32-bit memory management.
1. 32-bit memory management
All 32-bit systems can natively address a maximum of 4GB of memory (232
= 4,294,967,296 bytes). Until recent times, this limitation wasn't an
issue; a quick scan of older documentation reveals terms such as very large when referring to memory beyond 4GB. In today's terms, systems with 8 or 16GB of RAM are considered normal, making correct memory configuration in 32-bit systems very important in order to derive the maximum performance benefit.
Apart from installing 64-bit versions of Windows
and SQL Server, there are two ways of providing SQL Server with more
than 2GB of memory; using the /3GB option or using Address Windowing Extensions (AWE) with the /PAE option.
/3GB
Of the 4GB of RAM that a 32-bit system can
natively address, 2GB is reserved by Windows, leaving applications such
as SQL Server with a maximum of 2GB. In Windows Server 2003, we used the
/3GB option in the boot.ini file to limit Windows to 1GB of
memory, enabling SQL Server to access up to 3GB. In Windows Server 2008,
we use the BCDEdit command with the increaseuserva option with an optional parameter that determines the size of the available user space, such as 3072 for 3GB.
For 32-bit systems with 4GB of RAM, these
options are a good way of squeezing more memory out of Windows for use
by SQL Server, but limiting Windows to 1GB of RAM isn't always trouble
free, particularly on systems with a large number of drivers and/or
drivers that use a large amount of memory. Depending on the server
configuration, these options may actually reduce performance and
reliability, so use them with care.
For 32-bit systems with more than 4GB of RAM, we can use the /PAE option.
Pae and Awe
Intel first introduced 36-bit Physical Address Extensions
(PAEs) in the Pentium Pro in the late 1990s. The extra 4 bits enable
applications to acquire physical memory above 4GB (up to 64GB) as
nonpaged memory dynamically mapped in the 32-bit address space.
You enable the /PAE option in Windows Server 2003 in the boot.ini in the same way as the /3GB option. In Windows Server 2008, use the BCDEdit command with the /PAE
option. After enabling PAE, you configure SQL Server with AWE to enable
it to access the increased memory. You enable AWE either by using the sp_configure command or via the Server Properties window in SQL Server Management Studio (see figure 1).
Despite the increased memory that can be
accessed with PAE/AWE, there are some limitations when used by SQL
Server in 32-bit environments:
Memory above 4GB accessed using PAE/AWE
can only be used by the SQL Server data cache. The procedure cache, used
for query compilation plans, isn't able to take advantage of this
memory.
Analysis Services and Integration Services components aren't able to utilize memory accessed using PAE/AWE.
Unlike a flat 64-bit environment, there's some overhead in mapping into the AWE memory space in 32-bit systems.
On 32-bit AWE-enabled systems, the service
account running the SQL Server service must be given the Lock Pages in
Memory right. As a consequence, AWE memory isn't paged out to disk by
the operating system. As you can see in figure 2, you assign this right to an account by using the Windows Group Policy Editor.
So if the /PAE option allows us to address memory above 4GB and /3GB
allows us to get an extra 1GB from Windows below 4GB, then to obtain
the maximum amount of memory for SQL Server we should use both, right?
Well, maybe not...
/3GB AND /PAE
When using PAE, Windows uses memory below 4GB to map to memory above
4GB. The more memory above 4GB to map to, the more memory below 4GB is
required for the mapping. The magic number is 16GB. As shown in table 1, for systems with more than 16GB of memory, you must not use /3GB (or increaseuserva in Windows Server 2008) with /PAE. If you do, only 16GB will be addressable, and any additional memory beyond that is wasted.
Table 1. Recommended memory configuration options
Startup option | Use if system RAM is... |
---|
Default settings | <4GB |
/3GB (or increaseuserva) | 4GB |
/3GB and /PAE | 5-16GB |
/PAE | >16GB |
As I mentioned earlier, the /3GB option
is known to cause stability issues in some circumstances, so even with
systems containing between 5GB and 16GB of RAM, you must use this
setting with caution.
One of the nice things about 64-bit systems is that all of the configuration issues we've just covered are no longer of concern.
2. 64-bit memory management
Unlike 32-bit systems, 64-bit systems don't
require the memory configuration just described. The full complement of
system RAM can be accessed by all SQL Server components without any
additional configuration.
The one optional memory configuration for 64-bit
systems is setting the Lock Pages in Memory right, as covered earlier.
While this setting is optional for a 64-bit system, locking pages in
memory is beneficial in order to prevent Windows from paging out SQL
Server's memory. If you don't enable this setting, certain actions such
as large file copies can lead to memory pressure with Windows paging, or
trimming, SQL Server's memory. This
sometimes leads to a sudden and dramatic reduction in SQL Server
performance, usually accompanied by the "A significant part of sql
server process memory has been paged out..." message. Setting the Lock
Pages in Memory option prevents such incidents from occurring, and is
therefore a recommended setting. Note that Windows Server 2008 handles
memory trimming a lot better than 2003.
Regardless of the processor platform (32- or
64-bit), one of the important memory configuration tasks is to set the
minimum and maximum server memory values.